using PKGames.AssetBundleSystem;
using System;
using System.Collections;
using UnityEngine;

[Serializable]
public class ResourceAsset
{
	[ObjectPath]
	[SerializeField]
	private ResourceInfo _info;

	public ResourceInfo Info
	{
		get
		{
			return _info;
		}
		set
		{
			_info = value;
		}
	}

	public bool IsEmpty => Info == null || string.IsNullOrEmpty(Info.AssetGuid);

	public T Asset<T>() where T : UnityEngine.Object
	{
		return PKGames.AssetBundleSystem.Resources.Load<T>(_info.AssetName, _info.AssetBundleName);
	}

	public void SetInfo(string guid, string assetBundleName, string assetName)
	{
	}

	public IEnumerator AsyncAsset<T>(Action<T> onComplete, Action<float> onProgress = null) where T : UnityEngine.Object
	{
		T assetToReturn = (T)(T)null;
		yield return PKGames.AssetBundleSystem.Resources.LoadAsync(_info.AssetName, delegate(T asset)
		{
			assetToReturn = (T)asset;
		}, onProgress);
		onComplete.Fire((T)assetToReturn);
	}

	public static void ReapplyShader(UnityEngine.Object obj)
	{
		GameObject gameObject = obj as GameObject;
		if (!(gameObject != null))
		{
			return;
		}
		Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
		Renderer[] array = componentsInChildren;
		foreach (Renderer renderer in array)
		{
			if (!(renderer != null) || renderer.sharedMaterials == null)
			{
				continue;
			}
			Material[] sharedMaterials = renderer.sharedMaterials;
			foreach (Material material in sharedMaterials)
			{
				if (material != null && material.shader != null)
				{
					Shader shader2 = material.shader = Shader.Find(material.shader.name);
				}
			}
		}
	}
}
